﻿//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// <copyright>
//     Copyright (c) Artur Mustafin. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using Expressions.Compiler;
using Expressions.Compiler.Interfaces;
using Math.Compiler;

namespace Math.Compiler.Expressions
{
    internal partial class NonterminalsDefinition
    {
        private static Rules<char> _expression()
        {
            return new Rules<char> 
            {
                () => function_definition[false] + Terminal<char>.Default,       
                () => E[false] + Terminal<char>.Default
            };
        }
    }

    internal partial class ExpressionsDefinition
    {
        private static Func<MathExpression, IExpressionTree<char>, MathExpression> _expression()
        {
            return (a, b) =>
            {
                if (b[0].Context.Token.Equals(NonterminalsDefinition.function_definition))
                {
                    return function_definition[a, b[0]];
                }
                if (b[0].Context.Token.Equals(NonterminalsDefinition.E))
                {
                    return E[a, b[0]];
                }
                throw new NotSupportedException("Input token is not supported");
            };
        }
    }
}
